var icon = "#fUI/UIToolTip.img/Item/Equip/Star/Star#";
var icon2 = "#fUI/Basic.img/BtMin2/normal/0#";
var typed = 1;
var cost = 5;
var itemid = 0;
var paynx = 20;
var equip = null;
var btnOk = "#fUI/CashShop.img/CSCoupon/BtOK/normal/0#";
var btnOk_disabled = "#fUI/CashShop.img/CSCoupon/BtOK/disabled/0#";
var isUpgrade = false;
var dropGrade = 0;
var successRate = 0;
var position = -1;

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(b, f, g) {
    if (status == 0 && b == 0) {
        cm.dispose();
        return
    }
    if (b == 1) {
        status++
    } else {
        status--
    }
    if (status == 0) {
        var j = "你要将有期限的神级觉醒翅膀进行永久强化吗……\r\n#b";
        j += "#L2#" + icon2 + " 是的，快把他变为永久#l\r\n";
        cm.askMenu(j)
    } else {
        if (status == 1) {
            if (g == 2) {
                position = -1;
                isUpgrade = false;
                inventoryType = 1;
                var d = cm.getInventory(inventoryType).list();
                var c = d.iterator();
                j = "#e请选择翅膀#n\r\n\r\n#b";
                var e = 1;
                newItemList = Array();
                while (c.hasNext()) {
                    var k = c.next();
                    if (k.getItemId() != 1102310) {
                        continue
                    }
                    newItemList[k.getPosition()] = k.getItemId()
                }
                for (var h in newItemList) {
                    j += "#L" + h + "##v" + newItemList[h] + "#";
                    if (e > 1 && e % 5 == 0) {
                        j += "\r\n"
                    }
                    e++
                }
                cm.askMenu(j)
            }
        } else {
            if (status == 2) {
                if (position == -1) {
                    position = g
                }
                if (position != -1) {
                    if (cm.getTotalRMB() >= 500) {
                        equip = cm.getInventory(1).getItem(position);
                        var i = cm.getItemInfo();
                        var a = equip.copy();
                        a.setExpiration(-1);
                        cm.removeItem(position, 1, 1);
                        cm.addFromDrop(cm.getC(), a, false);
                        cm.worldMessageItem("[翅膀进阶] : 玩家[" + cm.getPlayer().getName() + "]将 神级觉醒<" + cm.getItemName(1102310) + "> 进阶为 永久", a);
                        cm.sendOk("进阶成功！");
                        cm.dispose()
                    } else {
                        cm.sendOk("充值累计不足500，无法进阶");
                        cm.dispose()
                    }
                }
            } else {
                if (status == 2) {}
            }
        }
    }
}
var status = -1;